import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.*;

class Employee implements Comparator<Employee>, Comparable<Employee>{
   private String name;
   private int age;
   Employee(){
   }

   Employee(String n, int a){
      name = n;
      age = a;
   }

   public String getEmployeeName(){
      return name;
   }

   public int getEmployeeAge(){
      return age;
   }

   // Overriding the compareTo method
   public int compareTo(Employee d){
      return (this.name).compareTo(d.name);
   }

   // Overriding the compare method to sort the age 
   public int compare(Employee d, Employee d1){
      return d.age - d1.age;
   }
}

public class Example{

   public static void main(String args[]){
      // Takes a list o Employee objects
      List<Employee> list = new ArrayList<Employee>();

      list.add(new Employee("Shaggy",3));
      list.add(new Employee("Lacy",2));
      list.add(new Employee("Roger",10));
      list.add(new Employee("Tommy",4));
      list.add(new Employee("Tammy",1));
      Collections.sort(list);// Sorts the array list

      for(Employee a: list)//printing the sorted list of names
         System.out.print(a.getEmployeeName() + ", ");

      // Sorts the array list using comparator
      Collections.sort(list, new Employee());
      System.out.println(" ");
      for(Employee a: list)//printing the sorted list of ages
         System.out.print(a.getEmployeeName() +"  : "+
		 a.getEmployeeAge() + ", ");
   }
}